﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using dhDataAcess.produceLinq;
using dhSystemBLL.produceBLL ;
using dhSystemBLL.orderData;
using baseSet;
using dhDataAcess.dataAcess.produceDataSetTableAdapters;
using dhDataAcess.dataAcess;
using baseSet.importExport;
using dhDataAcess.baseBLL;
using FastReport;

namespace dhsystem.produceForm.pdrk
{
    public partial class FrmpdfpjlbAdd : Form
    {
        
       // pdfpjlbModel pdfpjlbRow = new pdfpjlbModel();
        productListBLL product = new productListBLL();

       pdpqbBLL pdpqb = new pdpqbBLL();
       pdfpjlbBLL pdfpjlb = new pdfpjlbBLL();
        orderDetailBLL orderDetail = new orderDetailBLL();
        productUnitBLL productunit = new productUnitBLL();
      //  pdfpjlbBLL pdfpjlb = new pdfpjlbBLL();
        BindingSource BindingSourcepdfpjlbAdd;
        string state;
       string billoNo;
       string yujiqty;
        produceDataSet.pdfpjlbDataTable pdfpjilbTable = new produceDataSet.pdfpjlbDataTable();
        public FrmpdfpjlbAdd(BindingSource _bindingSourcepdfpjlb, string _state, string _billoNo, string _yujiqty)
        {
            InitializeComponent();
            BindingSourcepdfpjlbAdd = _bindingSourcepdfpjlb;
            state = _state;
            billoNo = _billoNo;
            yujiqty = _yujiqty;
        }
        //打开窗口时绑定数据
        private void FrmpdfpjlbAdd_Load(object sender, EventArgs e)
        {
            //textqty.Text = "0";
            textpdfw.Text = "漂染部";
            textbilloNo.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "billoNo");
            textorderDetailNo.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "orderDetailNo");
            textpname.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "pname");
            textunit.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "unit");
            textmachineNo.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "machineNo");
            textpdopen.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "pdopen");
            textproductopen.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "productopen");
            textpiaorandate.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "piaoranDate");
            textcustPo.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "custPoNo");
            textorderDate.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "orderDate");
             textorderQty.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "qty");
            textsehao.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "colorNum");
            textjiaohuoDate.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "createDate");
            textstockQty.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "stockQty");
            textcolor.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "pcolor");
            textpdweight.Text = basicSql.getgrwightbyproductList(textpname.Text);
           // textunit.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "unit");
            


            if (state == "编辑")
            {
          
                //textorderDetailNo.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "orderDetailNo");
                //textpname.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "pname");
                //textsendQty.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "sendQty");
                //textunit.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "unit");
               // dateTimesendDate.DataBindings.Add("value", BindingSourcepdfpjlbAdd, "sendDate");
    
                //textqty.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "qty");
       
                textmark.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "mark");

                textpiaorandate.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "piaoranDate");
                textmachineNo.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "machineNo");
                textpdopen.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "pdopen");
                textproductopen.DataBindings.Add("text", BindingSourcepdfpjlbAdd, "productopen");
                textsendqtyL.DataBindings.Add("value", BindingSourcepdfpjlbAdd, "sendqtyL");
            }
            if (state == "欠数")
            {


                textqianshu.Text = yujiqty;
            }
        }

        //退出按钮
        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void buttworkerselect_Click(object sender, EventArgs e)
        {
            string field;
            field = "orderDetailNo";
            Frmprodutselect productselect = new Frmprodutselect(moduleInfo.orderDetail, field);
            DialogResult result = productselect.ShowDialog();
            if (result == DialogResult.Yes)
            {
                textorderDetailNo.Text = productselect.pname;
            }
        }


        //菜单栏保存按钮
        private void toolSave_Click(object sender, EventArgs e)
        {
            if (state == "新增")
            {
                if (textyujiqty.Text == "")
                {
                    MessageBox.Show("请输入预大数");
                }
                if (textsendQty.Text == "")
                {
                    MessageBox.Show("请输入发胚重量");
                }
                if (textsendQty.Text == "")
                {
                    MessageBox.Show("请输入发胚啰数");
                }
                if (textsendqtyJ.Text == "")
                {
                    MessageBox.Show("请输入发胚件数");
                }
                else
                {
                    try
                    {
                        DialogResult result = MessageBox.Show("是否新增发胚记录！", "提示信息", MessageBoxButtons.YesNo);
                        if (result == DialogResult.Yes)
                        {
                            produceDataSet.pdfpjlbRow pdfpjlbRow = pdfpjilbTable.NewpdfpjlbRow();
                            pdfpjlbRow.billoNo = textbilloNo.Text;
                            pdfpjlbRow.orderDetailNo = textorderDetailNo.Text;
                            pdfpjlbRow.pname = textpname.Text;
                            //pdfpjlbRow.sendDate = dateTimesendDate.Value;
                            pdfpjlbRow.sendQty = Convert.ToDecimal(textsendQty.Text);
                            pdfpjlbRow.unit = textunit.Text;
                            //pdfpjlbRow.qty = Convert.ToDecimal(textqty.Text);
                            pdfpjlbRow.dyeDate = DateTime.Now;
                            pdfpjlbRow.dyestatus = "";
                            pdfpjlbRow.billStatus = "已发胚";
                            pdfpjlbRow.piaoranDate = Convert.ToDateTime(textpiaorandate.Text);
                            pdfpjlbRow.pdopen = textpdopen.Text;
                            pdfpjlbRow.productopen = textproductopen.Text;
                            pdfpjlbRow.machineNo = textmachineNo.Text;
                            pdfpjlbRow.sendqtyL = Convert.ToDecimal(textsendqtyL.Text);
                            pdfpjlbRow.createDate = DateTime.Now;
                            pdfpjlbRow.createUser = GlobalInfo.UserName;
                            pdfpjlbRow.updateDate = DateTime.Now;
                            pdfpjlbRow.updateUser = GlobalInfo.UserName;
                            pdfpjlbRow.mark = textmark.Text;
                            pdfpjlbRow.pdfw = textpdfw.Text;
                            pdfpjlbRow.pdenough = checkpdenough.Checked;
                            pdfpjlbRow.sendqtyJ = Convert.ToDecimal(textsendqtyJ.Text);
                            pdfpjlbRow.yujiqty = Convert.ToDecimal(textyujiqty.Text);
                            pdfpjlbRow.sendDate = DateTime.Now;
                            pdfpjilbTable.AddpdfpjlbRow(pdfpjlbRow);
                            pdfpjilbTable.AcceptChanges();
                            pdfpjlb.pdfpjlbInsert(pdfpjilbTable);
                            bindingSourcepdfpjlb.DataSource = pdfpjlb.getpdfpjlbAll();
                            basicSql.getpdpqbbillStatusUpdate(textbilloNo.Text, "已发胚");
                            basicSql.getdetailStatusUpdate(textorderDetailNo.Text ,"已发胚");
                            basicSql.getproductawightUpdate(textpname.Text, textpdweight.Text);

                            //string orderDetailNo = dGridyifp.CurrentRow.Cells["orderDetailNo"].Value.ToString();
                            Report r = new Report();
                            DataSet ds = new DataSet();
                            ds.Tables.Add(pdfpjlb.getV_piaoranorderAllBybilloNo(textbilloNo.Text));
                          // r.Load(@"E:\东华软件项目\报表\piaoranorder.frx");
                            r.Load(@"\\192.168.0.27\东华软件\报表\piaoranorder.frx");
                            r.RegisterData(ds);
                           // r.Design();
                           //r.Show();
                            r.Print();
                            //MessageBox.Show("新增成功");

                            //dGridorderDetail.DataSource =pdpqb .getV_piaoranpaiqiAllByorderDetailNo (textorderDetailNo.Text);
                            //DcolumnSet.colSet(moduleInfo.V_piaoranpaiqi, dGridorderDetail);
                            

                        }
                    }
                    catch (FormatException ex)
                    {
                        MessageBox.Show(ex.Message.ToString());
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message.ToString());
                    }
                }
            }
            if (state == "欠数")
            {
                if (textyujiqty.Text == "")
                {
                    MessageBox.Show("请输入预大数");
                }
                if (textsendQty.Text == "")
                {
                    MessageBox.Show("请输入发胚重量");
                }
                if (textsendQty.Text == "")
                {
                    MessageBox.Show("请输入发胚啰数");
                }
                if (textsendqtyJ.Text == "")
                {
                    MessageBox.Show("请输入发胚件数");
                }
                else
                {
                    try
                    {
                        DialogResult result = MessageBox.Show("是否新增发胚记录！", "提示信息", MessageBoxButtons.YesNo);
                        if (result == DialogResult.Yes)
                        {
                            produceDataSet.pdfpjlbRow pdfpjlbRow = pdfpjilbTable.NewpdfpjlbRow();
                            pdfpjlbRow.billoNo = textbilloNo.Text;
                            pdfpjlbRow.orderDetailNo = textorderDetailNo.Text;
                            pdfpjlbRow.pname = textpname.Text;
                            //pdfpjlbRow.sendDate = dateTimesendDate.Value;
                            pdfpjlbRow.sendQty = Convert.ToDecimal(textsendQty.Text);
                            pdfpjlbRow.unit = textunit.Text;
                            //pdfpjlbRow.qty = Convert.ToDecimal(textqty.Text);
                            pdfpjlbRow.dyeDate = DateTime.Now;
                            pdfpjlbRow.dyestatus = "";
                            pdfpjlbRow.billStatus = "已发胚";
                            pdfpjlbRow.piaoranDate = Convert.ToDateTime(textpiaorandate.Text);
                            pdfpjlbRow.pdopen = textpdopen.Text;
                            pdfpjlbRow.productopen = textproductopen.Text;
                            pdfpjlbRow.machineNo = textmachineNo.Text;
                            pdfpjlbRow.sendqtyL = Convert.ToDecimal(textsendqtyL.Text);
                            pdfpjlbRow.createDate = DateTime.Now;
                            pdfpjlbRow.createUser = GlobalInfo.UserName;
                            pdfpjlbRow.updateDate = DateTime.Now;
                            pdfpjlbRow.updateUser = GlobalInfo.UserName;
                            pdfpjlbRow.mark = textmark.Text;
                            pdfpjlbRow.pdfw = textpdfw.Text;
                            pdfpjlbRow.pdenough = checkpdenough.Checked;
                            pdfpjlbRow.sendqtyJ = Convert.ToDecimal(textsendqtyJ.Text);
                            pdfpjlbRow.yujiqty = Convert.ToDecimal(textyujiqty.Text);
                            pdfpjlbRow.sendDate = DateTime.Now;
                            pdfpjilbTable.AddpdfpjlbRow(pdfpjlbRow);
                            pdfpjilbTable.AcceptChanges();
                            pdfpjlb.pdfpjlbInsert(pdfpjilbTable);
                            bindingSourcepdfpjlb.DataSource = pdfpjlb.getpdfpjlbAll();
                            basicSql.getpdpqbbillStatusUpdate(textbilloNo.Text, "已发胚");
                            basicSql.getdetailStatusUpdate(textorderDetailNo.Text, "已发胚");
                            basicSql.getproductawightUpdate(textpname.Text, textpdweight.Text);

                            //string orderDetailNo = dGridyifp.CurrentRow.Cells["orderDetailNo"].Value.ToString();
                            Report r = new Report();
                            DataSet ds = new DataSet();
                            ds.Tables.Add(pdfpjlb.getV_piaoranorderAllBybilloNo(textbilloNo.Text));
                            //r.Load(@"E:\东华软件项目\报表\piaoranorderqianshu.frx");
                            r.Load(@"\\192.168.0.27\东华软件\报表\piaoranorderqianshu.frx");
                            r.RegisterData(ds);
                           //r.Design();
                            //r.Show();
                           r.Print();
                            //MessageBox.Show("新增成功");

                            //dGridorderDetail.DataSource =pdpqb .getV_piaoranpaiqiAllByorderDetailNo (textorderDetailNo.Text);
                            //DcolumnSet.colSet(moduleInfo.V_piaoranpaiqi, dGridorderDetail);
                        }
                    }
                    catch (FormatException ex)
                    {
                        MessageBox.Show(ex.Message.ToString());
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message.ToString());
                    }
                }
            }
            if (state == "编辑")
            {
                try
                {
                    DialogResult result = MessageBox.Show("是否修改原材料资料！", "提示信息", MessageBoxButtons.YesNo);
                    if (result == DialogResult.Yes)
                    {
                        //pdfpjlbRow.orderDetailNo = comboBoxorderDetailNo.SelectedValue.ToString();
                        //pdfpjlbRow.pname = comboBoxpname.SelectedValue.ToString();
                        //pdfpjlbRow.sendDate = dateTimesendDate.Value;
                        //pdfpjlbRow.unit = textunit.Text;
                        //pdfpjlbRow.qty = Convert.ToDecimal(textqty.Text);
                        //pdfpjlbRow.dyeDate = dateTimedyeDate.Value;
                        //pdfpjlbRow.dyestatus = textdyestatus.Text;
                        //pdfpjlbRow.billStatus = "";
                        //pdfpjlbRow.createDate = DateTime.Now;
                        //pdfpjlbRow.createUser = GlobalInfo.UserName;
                        //pdfpjlbRow.updateDate = DateTime.Now;
                        //pdfpjlbRow.updateUser = GlobalInfo.UserName;
                        //pdfpjlbRow.mark = textmark.Text;
                        //pdfpjlb.pdfpjlbUpdate (pdfpjlbRow);
                        //bindingSourcepdfpjlb.DataSource = pdfpjlb.getpdfpjlbAll();
                        //MessageBox.Show("修改成功");
                    }
                }
                catch (FormatException ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
            }
        }
        //菜单栏退出按钮
        private void toolExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        //textorderDetailNo值发生改变后的事件
        private void textorderDetailNo_TextChanged(object sender, EventArgs e)
        {

            //if (basicSql.getSendQty(textorderDetailNo.Text) == "")
            //{
            //    //textqty.Text = "0";
            //}
            //else
            //{
            //    //textqty.Text = basicSql.getSendQty(textorderDetailNo.Text);
            //}
           
          //  textpname .Text = basicSql.getpnamebyorderDetail(textorderDetailNo.Text);
          //  //comboBoxunit.Text = basicSql.getpnamebyorderDetail(textorderDetailNo.Text);
          //  textunit.Text = basicSql.getunitbyorderDetail(textorderDetailNo.Text);
          ////  textspareqty.Text =Convert .ToString ( Convert .ToDecimal ( basicSql.getqtybyorderDetail(textorderDetailNo.Text))-Convert .ToDecimal ( textqty .Text )); //-Convert .ToDecimal ( basicSql.getSendQty(textorderDetailNo.Text)));
          ////  bindingSourcepdfpjlb.DataSource = 
           //dGridorderDetail.DataSource = pdfpjlb.getpdfpjlbAllByorderDetailNo(textorderDetailNo.Text);

           // DcolumnSet.colSet(moduleInfo.pdfpjlb, dGridorderDetail);
        }
        //发胚数量值发生改变
        private void textsendQty_TextChanged(object sender, EventArgs e)
        {
            //if (textunit.Text == "GR")
            //{
            //    textsendQtyKg.Text = Convert.ToString(Convert.ToDouble(textsendQty.Text) * Convert.ToDouble(labelpwight.Text));

            //}
            //else
            //{
            //    textsendQtyKg.Text = Convert.ToString(Convert.ToDouble(textsendQty.Text) * Convert.ToDouble(basicSql.getUnitrateL(textunit.Text)) * Convert.ToDouble(labelpwight.Text));
            //}
            
        }
        //发胚数量公斤的值发生改变之后
        private void textsendQtyKg_TextChanged(object sender, EventArgs e)
        {
            try
            {
                //textsendQty.Text = ((Convert.ToDecimal(textsendQty.Text) / Convert.ToDecimal(textpdweight.Text)) * Convert.ToDecimal(basicSql.getUnitrateKgTo(textunit.Text))).ToString("#0.00");
                //textsendqtyL.Text = textsendQty.Text;
                textsendqtyL .Text =(Convert.ToDecimal(textsendQty.Text) / Convert.ToDecimal(textpdweight.Text)).ToString ("#0.00");
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message.ToString());
            }
            
        }

        private void textpname_TextChanged(object sender, EventArgs e)
        {
            textpdweight.Text = basicSql.getgrwightbyproductList(textpname.Text);
            textstockQty.Text = basicSql.getstockQtybyproductList (textpname .Text );
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (state == "新增")
            {
                if (textyujiqty.Text == "")
                {
                    MessageBox.Show("请输入预大数");
                }
                if (textsendQty.Text == "")
                {
                    MessageBox.Show("请输入发胚重量");
                }
                if (textsendQty.Text == "")
                {
                    MessageBox.Show("请输入发胚啰数");
                }
                if (textsendqtyJ.Text == "")
                {
                    MessageBox.Show("请输入发胚件数");
                }
                else
                {
                    try
                    {
                        DialogResult result = MessageBox.Show("是否新增发胚记录！", "提示信息", MessageBoxButtons.YesNo);
                        if (result == DialogResult.Yes)
                        {
                            produceDataSet.pdfpjlbRow pdfpjlbRow = pdfpjilbTable.NewpdfpjlbRow();
                            pdfpjlbRow.billoNo = textbilloNo.Text;
                            pdfpjlbRow.orderDetailNo = textorderDetailNo.Text;
                            pdfpjlbRow.pname = textpname.Text;
                            //pdfpjlbRow.sendDate = dateTimesendDate.Value;
                            pdfpjlbRow.sendQty = Convert.ToDecimal(textsendQty.Text);
                            pdfpjlbRow.unit = textunit.Text;
                            //pdfpjlbRow.qty = Convert.ToDecimal(textqty.Text);
                            pdfpjlbRow.dyeDate = DateTime.Now;
                            pdfpjlbRow.dyestatus = "";
                            pdfpjlbRow.billStatus = "已发胚";
                            pdfpjlbRow.piaoranDate = Convert.ToDateTime(textpiaorandate.Text);
                            pdfpjlbRow.pdopen = textpdopen.Text;
                            pdfpjlbRow.productopen = textproductopen.Text;
                            pdfpjlbRow.machineNo = textmachineNo.Text;
                            pdfpjlbRow.sendqtyL = Convert.ToDecimal(textsendqtyL.Text);
                            pdfpjlbRow.createDate = DateTime.Now;
                            pdfpjlbRow.createUser = GlobalInfo.UserName;
                            pdfpjlbRow.updateDate = DateTime.Now;
                            pdfpjlbRow.updateUser = GlobalInfo.UserName;
                            pdfpjlbRow.mark = textmark.Text;
                            pdfpjlbRow.pdfw = textpdfw.Text;
                            pdfpjlbRow.pdenough = checkpdenough.Checked;
                            pdfpjlbRow.sendqtyJ = Convert.ToDecimal(textsendqtyJ.Text);
                            pdfpjlbRow.yujiqty = Convert.ToDecimal(textyujiqty.Text);
                            pdfpjlbRow.sendDate = DateTime.Now;
                            pdfpjilbTable.AddpdfpjlbRow(pdfpjlbRow);
                            pdfpjilbTable.AcceptChanges();
                            pdfpjlb.pdfpjlbInsert(pdfpjilbTable);
                            bindingSourcepdfpjlb.DataSource = pdfpjlb.getpdfpjlbAll();
                            basicSql.getpdpqbbillStatusUpdate(textbilloNo.Text, "已发胚");
                            basicSql.getdetailStatusUpdate(textorderDetailNo.Text, "已发胚");
                            basicSql.getproductawightUpdate(textpname.Text, textpdweight.Text);
                        
                            //string orderDetailNo = dGridyifp.CurrentRow.Cells["orderDetailNo"].Value.ToString();
                            Report r = new Report();
                            DataSet ds = new DataSet();
                            ds.Tables.Add(pdfpjlb.getV_piaoranorderAllBybilloNo(textbilloNo.Text));
                            // r.Load(@"E:\东华软件项目\报表\piaoranorder.frx");
                            r.Load(@"\\192.168.0.27\东华软件\报表\piaoranorder.frx");
                            r.RegisterData(ds);
                            // r.Design();
                            //r.Show();
                            r.Print();
                            //MessageBox.Show("新增成功");

                            //dGridorderDetail.DataSource =pdpqb .getV_piaoranpaiqiAllByorderDetailNo (textorderDetailNo.Text);
                            //DcolumnSet.colSet(moduleInfo.V_piaoranpaiqi, dGridorderDetail);


                        }
                    }
                    catch (FormatException ex)
                    {
                        MessageBox.Show(ex.Message.ToString());
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message.ToString());
                    }
                }
            }
            if (state == "欠数")
            {
                if (textyujiqty.Text == "")
                {
                    MessageBox.Show("请输入预大数");
                }
                if (textsendQty.Text == "")
                {
                    MessageBox.Show("请输入发胚重量");
                }
                if (textsendQty.Text == "")
                {
                    MessageBox.Show("请输入发胚啰数");
                }
                if (textsendqtyJ.Text == "")
                {
                    MessageBox.Show("请输入发胚件数");
                }
                else
                {
                    try
                    {
                        DialogResult result = MessageBox.Show("是否新增发胚记录！", "提示信息", MessageBoxButtons.YesNo);
                        if (result == DialogResult.Yes)
                        {
                            produceDataSet.pdfpjlbRow pdfpjlbRow = pdfpjilbTable.NewpdfpjlbRow();
                            pdfpjlbRow.billoNo = textbilloNo.Text;
                            pdfpjlbRow.orderDetailNo = textorderDetailNo.Text;
                            pdfpjlbRow.pname = textpname.Text;
                            //pdfpjlbRow.sendDate = dateTimesendDate.Value;
                            pdfpjlbRow.sendQty = Convert.ToDecimal(textsendQty.Text);
                            pdfpjlbRow.unit = textunit.Text;
                            //pdfpjlbRow.qty = Convert.ToDecimal(textqty.Text);
                            pdfpjlbRow.dyeDate = DateTime.Now;
                            pdfpjlbRow.dyestatus = "";
                            pdfpjlbRow.billStatus = "已发胚";
                            pdfpjlbRow.piaoranDate = Convert.ToDateTime(textpiaorandate.Text);
                            pdfpjlbRow.pdopen = textpdopen.Text;
                            pdfpjlbRow.productopen = textproductopen.Text;
                            pdfpjlbRow.machineNo = textmachineNo.Text;
                            pdfpjlbRow.sendqtyL = Convert.ToDecimal(textsendqtyL.Text);
                            pdfpjlbRow.createDate = DateTime.Now;
                            pdfpjlbRow.createUser = GlobalInfo.UserName;
                            pdfpjlbRow.updateDate = DateTime.Now;
                            pdfpjlbRow.updateUser = GlobalInfo.UserName;
                            pdfpjlbRow.mark = textmark.Text;
                            pdfpjlbRow.pdfw = textpdfw.Text;
                            pdfpjlbRow.pdenough = checkpdenough.Checked;
                            pdfpjlbRow.sendqtyJ = Convert.ToDecimal(textsendqtyJ.Text);
                            pdfpjlbRow.yujiqty = Convert.ToDecimal(textyujiqty.Text);
                            pdfpjlbRow.sendDate = DateTime.Now;
                            pdfpjilbTable.AddpdfpjlbRow(pdfpjlbRow);
                            pdfpjilbTable.AcceptChanges();
                            pdfpjlb.pdfpjlbInsert(pdfpjilbTable);
                            bindingSourcepdfpjlb.DataSource = pdfpjlb.getpdfpjlbAll();
                            basicSql.getpdpqbbillStatusUpdate(textbilloNo.Text, "已发胚");
                            basicSql.getdetailStatusUpdate(textorderDetailNo.Text, "已发胚");
                            basicSql.getproductawightUpdate(textpname.Text, textpdweight.Text);

                            //string orderDetailNo = dGridyifp.CurrentRow.Cells["orderDetailNo"].Value.ToString();
                            Report r = new Report();
                            DataSet ds = new DataSet();
                            ds.Tables.Add(pdfpjlb.getV_piaoranorderAllBybilloNo(textbilloNo.Text));
                            //r.Load(@"E:\东华软件项目\报表\piaoranorderqianshu.frx");
                            r.Load(@"\\192.168.0.27\东华软件\报表\piaoranorderqianshu.frx");
                            r.RegisterData(ds);
                            //r.Design();
                            //r.Show();
                            r.Print();
                            //MessageBox.Show("新增成功");

                            //dGridorderDetail.DataSource =pdpqb .getV_piaoranpaiqiAllByorderDetailNo (textorderDetailNo.Text);
                            //DcolumnSet.colSet(moduleInfo.V_piaoranpaiqi, dGridorderDetail);
                        }
                    }
                    catch (FormatException ex)
                    {
                        MessageBox.Show(ex.Message.ToString());
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message.ToString());
                    }
                }
            }
            if (state == "编辑")
            {

                try
                {
                    DialogResult result = MessageBox.Show("是否修改原材料资料！", "提示信息", MessageBoxButtons.YesNo);
                    if (result == DialogResult.Yes)
                    {
                        //pdfpjlbRow.orderDetailNo = comboBoxorderDetailNo.SelectedValue.ToString();
                        //pdfpjlbRow.pname = comboBoxpname.SelectedValue.ToString();
                        //pdfpjlbRow.sendDate = dateTimesendDate.Value;
                        //pdfpjlbRow.unit = textunit.Text;
                        //pdfpjlbRow.qty = Convert.ToDecimal(textqty.Text);
                        //pdfpjlbRow.dyeDate = dateTimedyeDate.Value;
                        //pdfpjlbRow.dyestatus = textdyestatus.Text;
                        //pdfpjlbRow.billStatus = "";
                        //pdfpjlbRow.createDate = DateTime.Now;
                        //pdfpjlbRow.createUser = GlobalInfo.UserName;
                        //pdfpjlbRow.updateDate = DateTime.Now;
                        //pdfpjlbRow.updateUser = GlobalInfo.UserName;
                        //pdfpjlbRow.mark = textmark.Text;
                        //pdfpjlb.pdfpjlbUpdate (pdfpjlbRow);
                        //bindingSourcepdfpjlb.DataSource = pdfpjlb.getpdfpjlbAll();
                        //MessageBox.Show("修改成功");
                    }
                }
                catch (FormatException ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
            }
        }
        //产品名称的值发生改变时
        //private void textpname_TextChanged(object sender, EventArgs e)
        //{
        //   textpdweight.Text = basicSql.getgrwightbyproductList(textpname.Text );
        //}

        //private void textsendQty_MouseLeave(object sender, EventArgs e)
        //{
        //    //if (textunit.Text == "GR")
        //    //{
        //    //    textsendQtyKg.Text = Convert.ToString(Convert.ToDouble(textsendQty.Text) * Convert.ToDouble(labelpwight.Text));

        //    //}
        //    //else
        //    //{
        //    //    textsendQtyKg.Text = Convert.ToString(Convert.ToDouble(textsendQty.Text) * Convert.ToDouble(basicSql.getUnitrateL(textunit.Text)) * Convert.ToDouble(labelpwight.Text));
        //    //}
            
        //}

        //private void textsendQtyKg_MouseLeave(object sender, EventArgs e)
        //{
        //    //textsendQty.Text = Convert.ToString((Convert.ToDecimal(textsendQtyKg.Text) / Convert.ToDecimal(labelpwight.Text)) * Convert.ToDecimal(basicSql.getUnitrateKgTo(textunit.Text)));
            
        //    ////textsendQty.Text.Substring(0, 8);
        //}


    }
}
